﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:dssp="http://schemas.microsoft.com/xw/2004/10/dssp.html"
    xmlns:s="http://www.w3.org/2003/05/soap-envelope"
    xmlns:motor="http://schemas.microsoft.com/robotics/2006/05/motor.html"
    xmlns:encoder="http://schemas.microsoft.com/robotics/2006/05/encoder.html"
    xmlns:physical="http://schemas.microsoft.com/robotics/2006/07/physicalmodel.html"
    xmlns:vexrover="http://schemas.vexrobotics.com/2011/11/vex/roverdrive.html"
    >
  <xsl:import href="/resources/dss/Microsoft.Dss.Runtime.Home.MasterPage.xslt" />

  <xsl:template match="/">
    <xsl:comment>
      <!-- Service Header Info -->
    </xsl:comment>
    <xsl:variable name="title">
      VEX Rover Drive
    </xsl:variable>
    <xsl:variable name="serviceName">
      VEX Rover Drive
    </xsl:variable>
    <xsl:variable name="description">
      Controls the VEX motor configuration as a six-wheel independent drive.
    </xsl:variable>

    <xsl:call-template name="MasterPage">
      <xsl:with-param name="serviceName" select="$serviceName" />
      <xsl:with-param name="description" select="$description" />
      <!-- If title is not provided, serviceName will be used instead. -->
      <xsl:with-param name="title">
        <xsl:value-of select="$serviceName" />
        <xsl:if test="$title != ''">
          <xsl:text> - </xsl:text>
          <xsl:value-of select="$title" />
        </xsl:if>
      </xsl:with-param>
      <!-- Possible values for navigation are: 'Open', 'Closed', and 'None'
           'Open' is the default value. -->
      <xsl:with-param name="navigation" select="'Open'" />
      <!-- The contents of head param will be placed just before the </head> tag in html. -->
      <xsl:with-param name="head">
        <style type="text/css">
          /* Service-specific stylesheet goes here */
        </style>
        <script language="javascript" type="text/javascript">
          <![CDATA[<!--

/* Service-specific script goes here */

dssRuntime.init = function()
{
  // Add page initialization code here.
  // This function is attached to the window.onload event.
  // Do not override window.onload.
}

//-->     ]]>
        </script>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:template>

  <xsl:template match="vexrover:VEXRoverDriveState">

    <form method="POST" action="" name="ConfigurationForm">
      <table width="100%">
        <tr>
          <th colspan="2">VEX Mars Rover Drive</th>
        </tr>
        <tr>
          <table width="100%">
            <td width="50%">
              <table>
                <tr>
                  <td width="50%">
                    <table width="100%">
                      <tr>
                        <th colspan="2">Left Encoder</th>
                      </tr>
                      <tr>
                        <th width="50%">Identifier:</th>
                        <td>
                          <xsl:value-of select="vexrover:leftEncoder"/>
                        </td>
                      </tr>
                      <tr>
                        <th width="50%">Current Reading:</th>
                        <td>
                          <xsl:value-of select="vexrover:runtimeStatistics/vexrover:LeftEncoderCurrent"/>
                        </td>
                      </tr>
                      <tr>
                        <th width="50%">Target Reading:</th>
                        <td>
                          <xsl:value-of select="vexrover:runtimeStatistics/vexrover:LeftEncoderTarget"/>
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
                <tr>
                  <td width="50%">
                    <table width="100%">
                      <tr>
                        <th colspan="2">Left Front</th>
                      </tr>
                      <tr>
                        <th width="50%">Identifier:</th>
                        <td>
                          <xsl:value-of select="vexrover:leftFront/vexrover:MotorPort"/>
                        </td>
                      </tr>
                      <tr>
                        <th>Reverse Polarity:</th>
                        <td>
                          <xsl:value-of select="vexrover:leftFront/vexrover:ReversePolarity"/>
                        </td>
                      </tr>
                      <tr>
                        <th>Wheel Diameter:</th>
                        <td>
                          <xsl:value-of select="vexrover:leftFront/vexrover:WheelDiameter"/>
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
                <tr>
                  <td width="50%">
                    <table width="100%">
                      <tr>
                        <th colspan="2">Left Middle</th>
                      </tr>
                      <tr>
                        <th width="50%">Identifier:</th>
                        <td>
                          <xsl:value-of select="vexrover:leftMiddle/vexrover:MotorPort"/>
                        </td>
                      </tr>
                      <tr>
                        <th>Reverse Polarity:</th>
                        <td>
                          <xsl:value-of select="vexrover:leftMiddle/vexrover:ReversePolarity"/>
                        </td>
                      </tr>
                      <tr>
                        <th>Wheel Diameter:</th>
                        <td>
                          <xsl:value-of select="vexrover:leftMiddle/vexrover:WheelDiameter"/>
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
                <tr>
                  <td width="50%">
                    <table width="100%">
                      <tr>
                        <th colspan="2">Left Rear</th>
                      </tr>
                      <tr>
                        <th width="50%">Identifier:</th>
                        <td>
                          <xsl:value-of select="vexrover:leftRear/vexrover:MotorPort"/>
                        </td>
                      </tr>
                      <tr>
                        <th>Reverse Polarity:</th>
                        <td>
                          <xsl:value-of select="vexrover:leftRear/vexrover:ReversePolarity"/>
                        </td>
                      </tr>
                      <tr>
                        <th>Wheel Diameter:</th>
                        <td>
                          <xsl:value-of select="vexrover:leftRear/vexrover:WheelDiameter"/>
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
                <tr>
                  <td width="50%">
                    <table width="100%">
                      <th width="50%">Current Power:</th>
                      <td>
                        <input type="text" name="LeftPower" size="10">
                          <xsl:attribute name="value">
                            <xsl:value-of select="vexrover:runtimeStatistics/vexrover:LeftPowerCurrent"/>
                          </xsl:attribute>
                        </input>
                      </td>
                    </table>
                  </td>
                </tr>
              </table>
            </td>
            <td width="50%">
              <table>
                <tr>
                  <td width="50%">
                    <table width="100%">
                      <tr>
                        <th colspan="2">Right Encoder</th>
                      </tr>
                      <tr>
                        <th width="50%">Identifier:</th>
                        <td>
                          <xsl:value-of select="vexrover:rightEncoder"/>
                        </td>
                      </tr>
                      <tr>
                        <th width="50%">Current Reading:</th>
                        <td>
                          <xsl:value-of select="vexrover:runtimeStatistics/vexrover:RightEncoderCurrent"/>
                        </td>
                      </tr>
                      <tr>
                        <th width="50%">Target Reading:</th>
                        <td>
                          <xsl:value-of select="vexrover:runtimeStatistics/vexrover:RightEncoderTarget"/>
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
                <tr>
                  <td>
                    <table width="100%">
                      <th colspan="2">Right Front</th>
                      <tr>
                        <th width="50%">Identifier:</th>
                        <td>
                          <xsl:value-of select="vexrover:rightFront/vexrover:MotorPort"/>
                        </td>
                      </tr>
                      <tr>
                        <th>Reverse Polarity:</th>
                        <td>
                          <xsl:value-of select="vexrover:rightFront/vexrover:ReversePolarity"/>
                        </td>
                      </tr>
                      <tr>
                        <th>Wheel Diameter:</th>
                        <td>
                          <xsl:value-of select="vexrover:rightFront/vexrover:WheelDiameter"/>
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
                <tr>
                  <td>
                    <table width="100%">
                      <th colspan="2">Right Middle</th>
                      <tr>
                        <th width="50%">Identifier:</th>
                        <td>
                          <xsl:value-of select="vexrover:rightMiddle/vexrover:MotorPort"/>
                        </td>
                      </tr>
                      <tr>
                        <th>Reverse Polarity:</th>
                        <td>
                          <xsl:value-of select="vexrover:rightMiddle/vexrover:ReversePolarity"/>
                        </td>
                      </tr>
                      <tr>
                        <th>Wheel Diameter:</th>
                        <td>
                          <xsl:value-of select="vexrover:rightMiddle/vexrover:WheelDiameter"/>
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
                <tr>
                  <td>
                    <table width="100%">
                      <th colspan="2">Right Rear</th>
                      <tr>
                        <th width="50%">Identifier:</th>
                        <td>
                          <xsl:value-of select="vexrover:rightRear/vexrover:MotorPort"/>
                        </td>
                      </tr>
                      <tr>
                        <th>Reverse Polarity:</th>
                        <td>
                          <xsl:value-of select="vexrover:rightRear/vexrover:ReversePolarity"/>
                        </td>
                      </tr>
                      <tr>
                        <th>Wheel Diameter:</th>
                        <td>
                          <xsl:value-of select="vexrover:rightRear/vexrover:WheelDiameter"/>
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
                <tr>
                  <td width="50%">
                    <table width="100%">
                      <th width="50%">Current Power:</th>
                      <td>
                        <input type="text" name="RightPower" size="10">
                          <xsl:attribute name="value">
                            <xsl:value-of select="vexrover:runtimeStatistics/vexrover:RightPowerCurrent"/>
                          </xsl:attribute>
                        </input>
                      </td>
                    </table>
                  </td>
                </tr>
              </table>
            </td>
          </table>
        </tr>
        <input id="Button2" type="reset" value="Reset" name="buttonReset" title="Reset Configuration"/>
        <input type="submit" value="Stop" name="AllStop" title="Stop"/>
        <input type="submit" value="Set Power" name="CustomPower" title="Set The Motor Power"/>
      </table>
    </form>

    <form method="POST" action="" name="EnableForm">
      <table>
        <tr>
          <th width="20%">Is Enabled:</th>
          <td width="80%">
            <xsl:value-of select="vexrover:IsEnabled"/>
          </td>
        </tr>
        <tr class="odd">
          <th>Distance Between Wheels:</th>
          <td>
            <xsl:value-of select="vexrover:DistanceBetweenWheels"/>
          </td>
        </tr>
        <tr>
          <th></th>
          <td>
            <xsl:choose>
              <xsl:when test='vexrover:IsEnabled = "true"'>
                <input type="submit" value="Disable Drive" name="DisableDrive" title="Disable Drive"/>
              </xsl:when>
              <xsl:otherwise>
                <input type="submit" value="Enable Drive" name="EnableDrive" title="Enable Drive"/>
              </xsl:otherwise>
            </xsl:choose>
          </td>
        </tr>
      </table>
    </form>
  </xsl:template>
</xsl:stylesheet>
